import Vue from 'vue'
import axios from 'axios'
import qs from 'qs'

Vue.prototype.$http = axios
axios.defaults.baseURL = 'http://data.toutiaojk.com/extend/list/'

const ajaxURL = {
  //搜索页
  Search:'search.php'
}

export var request = async(type = 'POST',url = '',data = {}) =>{
  let result
  type = type.toUpperCase()
  url = ajaxURL[url]
  if(type === 'GET'){
    await axios.get(url,{params:data})
      .then(res =>{
          result = res.data
      })
  } else if(type === 'POST'){
     await  axios.post(url,{params:data})
       .then(res=>{
         result = res.data
       })
  }
  return result;
}
